home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 6 / MacMania 6.toast / / Tools&Utilities / EnterAct Stuff / EnterAct Code Templates next >
Text File  |  1997-01-07  |  5KB  |  337 lines

  1. About templates and this file format
  2. ------------------------------------
  3. If you didn't read the manual, you'll want to know how to use this:
  4. type the name of an entry, then hit <command><return> to replace
  5. the name with its template. To advance to the next logical insertion
  6. point, keep hitting <command><return>. Case counts in the template name.
  7.  
  8. hAWK templates are a special case (see the first entries below): if your
  9. entry name expands to something that starts with "hAWK", EnterAct will
  10. select all of it instead of advancing the insertion point. And if you
  11. press <command><return> with a hAWK template selected, EnterAct will
  12. run the hAWK program. You can also press <enter> to run a selected program,
  13. but note that pressing <enter> does not expand a code template, only
  14. <command><return> does that.
  15.  
  16. If you change and save this file with EnterAct, changes take effect
  17. immediately (no need to restart EnterAct). Keep this file in the same
  18. folder where you have EnterAct, at the same level, and don't change its name.
  19.  
  20. Please change this file to suit your needs--just follow the rules below.
  21. Feel free to add or delete entries, or change entry names or contents.
  22.  
  23. Keep each entry in an ENTRY/END sandwich. Following ENTRY, on a new line
  24. put the name of the template--note it can contain any non-blank characters.
  25. Put the template (or definition if you like) for the name on a new line
  26. immediately below the name line. Each template ends with "END" on a new
  27. line. Arbitrary text like this is OK between entries (just don't start any
  28. comment line, or for that matter any line inside a template,
  29. with "ENTRY" or "END"). The last <return> in the definition is not included,
  30. so put a blank line after your definition body if you want your definition
  31. to include a final <return>, as in the "echo" template just below.
  32.  
  33. If you put the special symbol '@' in your template, then insertion
  34. point advances (automatic when you put in a template, command-return
  35. thereafter) will stop at the '@' and select it. Non-code insertion points
  36. should be specially marked with '@', but you mostly don't have to specially
  37. mark obvious places in a C or C++ code template.
  38.  
  39. Keep all your entries flush-left, and EnterAct will adjust your indentation
  40. when pasting your template in. Just open up a new line and tab in to the
  41. right position before typing the entry name and pressing <command><return>.
  42.  
  43. Tip: if you change your templates a lot, add this file to your "Locations" menu.
  44.  
  45. There are six builtin variables that have special meanings inside templates:
  46.     @@clip, @@date (includes year), @@time, @@year, @@me, and @@mail.
  47. The first one, @@clip, stands for all the text from your last Cut or Copy, ie
  48. the contents of your current clipboard. Note that builtin variable names do
  49. not have to be followed by any white space, as in the "c" example which
  50. contains the line "@@clip*/" just below. "@@clipthis" would also work.
  51.  
  52. If you have used Internet Config to set your real name and email address,
  53. then @@me will become your name and @@mail your email address. For an
  54. example, see the "top" and "mail" templates down below.
  55.  
  56. Some examples using the builtin template variables:
  57. ENTRY
  58. t
  59. @@time
  60. END
  61. ENTRY
  62. d
  63. @@date
  64. END
  65. ENTRY
  66. y
  67. @@year
  68. END
  69.  
  70. ( "c" for comment out, and "0" (a zero) for #if 0 out. These are designed to
  71. work best on whole lines. Select one or more entire lines, Cut, type
  72. "c" or "0", then hit <command><return> )
  73. ENTRY
  74. c
  75. /*
  76. @@clip*/
  77.  
  78. END
  79. ENTRY
  80. 0
  81. #if 0
  82. @@clip#endif
  83.  
  84. END
  85.  
  86. (Put the name of the enum, eg ParseStates, on the clip first)
  87. ENTRY
  88. enum
  89. enum @@clip
  90.     {
  91.     e@@clip_@,
  92.     e@@clip_@
  93.     };
  94.  
  95. END
  96.  
  97. Some hAWK templates:
  98. ENTRY
  99. echo
  100. hAWK -f$EchoFullPathNames -- MFS
  101.  
  102. END
  103. ENTRY
  104. compare
  105. hAWK -f$CompareFiles -- MFS
  106.  
  107. END
  108. ENTRY
  109. boiler
  110. hAWK -f$BoilerPlate -vputInComment=1 -vfile="@.c"
  111.     -vauthor="KE" -vcompany="bdibdi" -ss
  112.  
  113. END
  114.  
  115. ENTRY
  116. time
  117. hAWK -f$Time
  118.  
  119. END
  120.  
  121. ENTRY
  122. ff
  123. hAWK -f$FormatFunctionIntro
  124.  
  125. END
  126.  
  127. Some standard templates:
  128.  
  129. ENTRY
  130. for
  131. for (; ; )
  132.     {
  133.     
  134.     }
  135.  
  136. END
  137. ENTRY
  138. fori
  139. for (i = 0; i < @; ++i)
  140.     {
  141.     
  142.     }
  143.  
  144. END
  145. ENTRY
  146. while
  147. while ()
  148.     {
  149.     
  150.     }
  151.  
  152. END
  153. ENTRY
  154. switch
  155. switch ()
  156.     {
  157. case :
  158.     
  159. break;
  160. default:
  161. break;
  162.     }
  163.  
  164. END
  165. ENTRY
  166. switch'
  167. switch ()
  168.     {
  169. case '':
  170.     
  171. break;
  172. default:
  173. break;
  174.     }
  175.  
  176. END
  177. ENTRY
  178. if
  179. if ()
  180.     {
  181.     
  182.     }
  183.  
  184. END
  185. ENTRY
  186. else
  187. else
  188.     {
  189.     
  190.     }
  191.  
  192. END
  193. ENTRY
  194. ife
  195. if ()
  196.     {
  197.     
  198.     }
  199. else
  200.     {
  201.     
  202.     }
  203.  
  204. END
  205. ENTRY
  206. iff
  207. if ()
  208.     {
  209.     
  210.     }
  211. else if ()
  212.     {
  213.     
  214.     }
  215.  
  216. END
  217. ENTRY
  218. elif
  219. else if ()
  220.     {
  221.     
  222.     }
  223.  
  224. END
  225. ENTRY
  226. do
  227. do
  228.     {
  229.     
  230.     } while ();
  231.  
  232. END
  233. ENTRY
  234. struct
  235. typedef struct @
  236.     {
  237.     ;    //
  238.     } @, *@Ptr;
  239.  
  240. END
  241.  
  242. If you type something a lot--make a template for it!
  243. Error checking, maybe...
  244. ENTRY
  245. e
  246. if (theErr == noErr)
  247.     {
  248.     
  249.     }
  250.  
  251. END
  252. ...or looping a lot
  253. ENTRY
  254. while--
  255. while (--@ >= 0)
  256.     {
  257.     
  258.     }
  259.  
  260. END
  261.  
  262. A quick&dirty file top
  263. --change the names below to your own, Save, and try it out by typing
  264. "top<command><return>" in a separate window.
  265. ENTRY
  266. top
  267. /****
  268.     File.....:    @
  269.     Date.....:    @@date
  270.     .........:    © @@year Dynabyte (@@me). All rights reserved.
  271.     Spec.....:    @
  272. ****/
  273.  
  274. END
  275. ENTRY
  276. mail
  277. @@mail (@@me)
  278. END
  279. ENTRY
  280. i
  281. #include "@.h"
  282.  
  283. END
  284.  
  285. Make a quick comment by typing just a forward slash, then cmd-return:
  286. ENTRY
  287. /
  288. /* @
  289. */
  290. END
  291.  
  292. Start up a function definition
  293. ENTRY
  294. func
  295. /* @
  296. */
  297. OSErr @
  298.     (,    //
  299.         //
  300.     )
  301.     {
  302.     
  303.     
  304.     
  305.     }
  306.  
  307. END
  308.  
  309. Dereference a Handle
  310. ENTRY
  311. d
  312. (**@).@
  313. END
  314.  
  315. An HTML template
  316. ENTRY
  317. html
  318. <HTML>
  319.  
  320. <HEAD>
  321. <TITLE>@</TITLE>
  322. </HEAD>
  323.  
  324. <BODY>
  325.  
  326. <H1>@</H1>
  327.  
  328. <P>@</P>
  329.  
  330. </BODY>
  331.  
  332. </HTML>
  333.  
  334. END
  335.  
  336. OK, your turn...a template for a class, perhaps?
  337.